﻿using System;
using System.Windows.Forms;
using DevExpress.XtraBars.Helpers;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraEditors;

namespace DX.Learning.SimpleUserControlInsertion
{
    public partial class MainForm : RibbonForm
    {
        public MainForm()
        {
            InitializeComponent();
            InitSkinGallery();
        }


        private void InitSkinGallery()
        {
            SkinHelper.InitSkinGallery(rgbiSkins, true);
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            

         
           // DisplayView(new XtraUserControl1());
        }

        public void DisplayView( XtraUserControl control)
        {
            if (control == null) throw new ArgumentNullException("control");
            pnlMainContainer.Controls.Clear();
            pnlMainContainer.Controls.Add(control);
            control.Dock = DockStyle.Fill;
        }

        public void Navigate<TControl>() where TControl : XtraUserControl, new()
        {
            pnlMainContainer.Controls.Clear();
            var control = new TControl();

            pnlMainContainer.Controls.Add(control);
            control.Dock = DockStyle.Fill;  
        }


        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Navigate<SimpleUserControl>();
            
        }

        private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Navigate<XtraUserControl1>();


        }

        private void barButtonItem4_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Navigate<MessageBoxView>();

        }
    }
}